var ruleBtn = document.getElementById('contrlIntro');
var ruleWindow = document.getElementsByClassName('lotto-rule-intro')[0];
var isOpen = false;
ruleBtn.addEventListener('click',function(){
	isOpen = !isOpen;
	if( isOpen ) {
		ruleBtn.children[0].style.color= 'limegreen';
	}else {
		ruleBtn.children[0].style.color= '#ffffff';
	}
    ruleWindow.style.transform = 'scale(1)';
});

//关闭规则弹窗
var closeBtn = document.getElementsByClassName('close-ico')[0];
closeBtn.addEventListener('click',function(){
	ruleBtn.children[0].style.color= '#ffffff';
	ruleWindow.style.transform = 'scale(0)';
})


/**
 * 抽奖
 */
// 获取转盘的奖项
var prizes = document.getElementsByClassName('lotto-item');
//当前的奖项
var now = 0;
function Lotto(star) {
	for( var j = 0; j < prizes.length; j++ ) {
		prizes[j].classList.remove('lotto-item-hover');
	}
	if( star == 4 ) {
		prizes[star+1].classList.add('lotto-item-hover');
		now++;
	}else if( star >= 9 ){
        star = 0;
        now = 0;
        prizes[now].classList.add('lotto-item-hover');
        now++;
	}else {
	    prizes[star].classList.add('lotto-item-hover');
	    now++;
	} 
}

/*
开始或者结束抽奖
 */
var lottoBtn = document.getElementById('start-lotto');
var isStart = false;
var lotto;
lottoBtn.addEventListener('click',function(){
    isStart = !isStart;
    if( isStart ) {
    	lotto = setInterval(function(){
   			Lotto(now);
		},80);
    }else {
    	clearInterval(lotto);
    	console.log(now-1);
    }
});